<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title> 支付表信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>

<script type="text/javascript">
    var grid = null;
    $(function () {
   	 var ligerForm = liger.get("rskArreExpLog_form");
		$("#rskArreExpLog_form").ligerForm({
		    validate: true
		});
        initForm();
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
        searchBtnEvent();
        clearBtnEvent();
    });

    //清空按钮事件
    function clearBtnEvent() {
        $("#clearBtn").click(function (event) {
            $("#resetBtn").click();  //重置 input-text
            var form = liger.get("searchBar");
            form.setData({  //重置select等特殊表单
                "lsCntNo": " ",
                "cstNm": " "
            });
        });
    }

    //初始化表单
    function initForm() {
        $("#searchBar").ligerForm();
    }

    //查询按钮事件
    function searchBtnEvent() {
        $("#searchBtn").click(function (event) {
            var form = new liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            ;
            grid.reload();
        });
    }

    //查询参数
    function getSearchParams() {
        var form = new liger.get("searchBar");
        var data = form.getData();
        return data;
    }

    //初始化列表
    function initGrid() {
        $("#ligergrid1").ligerGrid({
            url: '<%=path%>/project/prjprdpayschm/getPrjPrdPaySchMList.do',
            method: 'get',
            parms: getSearchParams(),
            columns: [
                {display: "客户名称", name: 'cstNm', minWidth: 100, enabledSort: true},
                {display: "合同号", name: 'lsCntNo', width: 150, enabledSort: true},
                {display: "支付表号", name: 'paySchNo', width: 150, enabledSort: true}
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(400);
    }

	function  arreExport(){
		    var selectedRows = grid.getSelectedRows();
	        if (selectedRows.length < 1) {
	            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
	            return;
	        }
	        var _ids = [];
	        for (var index in selectedRows) {
	            _ids.push(selectedRows[index].id);
	        } 
	   	<%--   var ligerForm = liger.get("rskArreExpLog_form");
	        var data = ligerForm.getData();
	        var url = '<%=path%>/risk/rskArreExpLogM/arreExport.do';
	        var ids=JSON.stringify(_ids);
	        var closDt=$("#closDt").val();
	        var overdueDay=$("#overdueDay").val();
	        var penaCalWay=$("#penaCalWay").val();
	        var expPd=$("#expPd").val();
	        var overdueClosDt=$("#overdueClosDt").val();
	        
	        window.location.href ='<%=path%>/risk/rskArreExpLogM/arreExport.do?ids='+ids+'&&closDt='+closDt+'&&expPd='+expPd+'&&penaCalWay='+penaCalWay+'&&overdueClosDt='+overdueClosDt;
	         --%>
	  /*       var wait_dialog;
	        $.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:data,
	    		url: url,
	    		beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
	    		success:function(msg){
	    			 wait_dialog.close();
	    			 if(msg.success == 1){
	    				 top.$.ligerDialog.SQalert({content: "导出成功！",SQ_type: "success"});
	    			 }else{
	    				 top.$.ligerDialog.SQalert({content: "导出失败！",SQ_type: "error"});
	    			 }
	    		}
	    	}); */
	        //关闭窗口
	        /* parent.$.ligerDialog.close();
	        parent.$(".l-dialog,.l-window-mask").css("display", "none"); */
	        

	        /*导出*/
	            var form = liger.get("rskArreExpLog_form");
	            var data = form.getData();
		        var url = '<%=path%>/risk/rskArreExpLogM/arreExport.do';
		       var ids=JSON.stringify(_ids);
		        data["ids"] = ids; 
	            var wait_dialog;
	            $.ajax({
	                type: 'post',
	                dataType:'json',
	                url: url,
	                data:data,
	                beforeSend:function(){
	                    wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
	                },
	                success:function(msg){
	                    wait_dialog.close();
	                    if(msg.success == 1){
	                        parent.liger.get("ligergrid1").reload();
	                        parent.$.ligerDialog.close();
	            	        parent.$(".l-dialog,.l-window-mask").css("display", "none");
	            	        var tempwindow= window.open("_blank");
	            	        tempwindow.location=msg.data;
	                    }else{
	                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	                    }
	                }
	            });


	        
	        
	}

    function clearBtn() {
        var form = new liger.get("searchBar");
        form.clear();
    }

    
     function setOverdueClosDt(){
    	 var closDt = $("#closDt").val();
    	 if(closDt){
    		 $("#overdueClosDt").val(closDt);
    	 }
     }
    
    function iframeResize() {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        }
        ;
    }

</script>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">合同号</div>
                    <div class="field">
                        <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_1"></i> -->查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round"><!-- <i class="sqBtnIco_19"></i> -->清空</span>
                </div>
            </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</div>
<form id="rskArreExpLog_form">
    <div class="fieldset1 tabel_col tabel_col_1 clearFix">
        <div class="fieldBox col_50">
            <div class="label">截至日期</div>
            <div class="field">
                <input name="closDt" id="closDt"  onblur="setOverdueClosDt()" type="text"  class="ui-datepicker"   value="" validate="{required:true}" >
                <span class="requiredSymbol">*</span>
            </div>
        </div>
           <div class="fieldBox col_50">
            <div class="label">应付金额导出期次</div>
            <div class="field">
                <select name="expPd" id="expPd" data-value=""  >
                    <option value="" checked >请选择</option>
					<c:forEach items="${expWayList }" var="kv">
					    <option value="${kv.key }" >${kv.value }</option>
					</c:forEach>
				 </select>
            </div>
        </div>
            <div class="fieldBox col_50">
            <div class="label">违约金计算方式</div>
            <div class="field">
                 <select name="penaCalWay" id="penaCalWay" data-value=""  >
                    <option value="" checked >请选择</option>
					<c:forEach items="${penaCalWayList }" var="kv">
					    <option value="${kv.key }" >${kv.value }</option>
					</c:forEach>
				 </select>
                <span class="requiredSymbol">*</span>
            </div>
        </div>
           <div class="fieldBox col_50">
            <div class="label">逾期天数截止时间</div>
            <div class="field">
                <input name="overdueClosDt" id="overdueClosDt" type="text"  class="ui-datepicker"  value="" validate="{required:true}" >
                <span class="requiredSymbol">*</span>
            </div>
        </div>
    
    </div>
    <div class="btnsBox">
        <span id="export_Btn"  onclick="arreExport();" class="sq-button sq-button-round l-dialog-btn-ok">生成并导出欠款明细</span>
    </div>

</form>
</body>
</html>
